package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PackageInfoMapper;
import com.ruoyi.system.domain.PackageInfo;
import com.ruoyi.system.service.IPackageInfoService;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@Service
public class PackageInfoServiceImpl extends ServiceImpl<PackageInfoMapper,PackageInfo> implements IPackageInfoService
{
    @Autowired
    private PackageInfoMapper packageInfoMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public PackageInfo selectPackageInfoById(Long id)
    {
        return packageInfoMapper.selectPackageInfoById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param packageInfo 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<PackageInfo> selectPackageInfoList(PackageInfo packageInfo,Integer pageNum,Integer pageSize)
    {
        LambdaQueryWrapper<PackageInfo> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(packageInfo.getPackageName())){
            queryWrapper.like(PackageInfo::getPackageName,packageInfo.getPackageName());
        }
        if(packageInfo.getIsEnable()!=null){
            queryWrapper.eq(PackageInfo::getIsEnable,packageInfo.getIsEnable());

        }
        List<PackageInfo> packageInfoList = packageInfoMapper.selectPage(new Page(pageNum,pageSize),queryWrapper).getRecords();
        return packageInfoList;
    }

    @Override
    public Long selectOrderqaInfoCount(PackageInfo packageInfo) {
        LambdaQueryWrapper<PackageInfo> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(packageInfo.getPackageName())){
            queryWrapper.like(PackageInfo::getPackageName,packageInfo.getPackageName());
        }
        if(packageInfo.getIsEnable()!=null){
            queryWrapper.eq(PackageInfo::getIsEnable,packageInfo.getIsEnable());

        }
        return packageInfoMapper.selectCount(queryWrapper);
    }

    @Override
    public List<PackageInfo> selectPackageInfoAll(PackageInfo packageInfo)
    {
        return packageInfoMapper.selectPackageInfoList(packageInfo);
    }
    @Override
    public List<PackageInfo> selectPackageInfoAll()
    {
        LambdaQueryWrapper<PackageInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PackageInfo::getIsEnable,1);
        List<PackageInfo> packageInfoList = packageInfoMapper.selectList(queryWrapper);
        return packageInfoList;
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param packageInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertPackageInfo(PackageInfo packageInfo)
    {
        return packageInfoMapper.insertPackageInfo(packageInfo);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param packageInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updatePackageInfo(PackageInfo packageInfo)
    {
        return packageInfoMapper.updatePackageInfo(packageInfo);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePackageInfoByIds(Long[] ids)
    {
        return packageInfoMapper.deletePackageInfoByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePackageInfoById(Long id)
    {
        return packageInfoMapper.deletePackageInfoById(id);
    }
}
